/* Bfgeshka, 2021
 * Made for version 3.6.0 */

var Utils = import Custom/BUtils.stone

var frame = 0
var loops = 0
var prevLoops = []

var foeStateCur = 0
var foeStateLast = 0
var foeStateFrames = 0

var smiteBuffs = 0
var armBuffs = 0

func OnUpdate ()
	frame++
	? loc.begin
		OnBegin()
	? loc.loop
		OnLoop()
	foeStateLast = foeStateCur
	foeStateCur = foe.state
	? foeStateCur = foeStateLast
		foeStateFrames++
	:
		foeStateFrames = 0
	CountBuffs()

func OnBegin ()
	return

func OnLoop ()
	? loops = 0
		prevLoops.Add(frame)
	:
		prevLoops.Insert( 0, frame )
	loops++
	frame = 0
	foeStateCur = 0
	foeStateLast = 0
	foeStateFrames = 0
	return

func CountBuffs ()
	smiteBuffs = 0
	armBuffs = 0
	? buffs.count = 0
		return
	var buffsarr = Utils.GetBuffArrFull(buffs.string)
	? !buffsarr | buffsarr.Count() = 0
		return
	for i = 0..buffsarr.Count() - 1
		? buffsarr[i] = "≡"
			armBuffs = int.Parse(buffsarr[i+2])
		? buffsarr[i] = "•"
			smiteBuffs = int.Parse(buffsarr[i+2])
		i++
		i++
